package com.itheima.d7_collections;

import java.util.*;

/**
 * 实现两种比较方式
 */
public class ComparaDemo3 {
    public static void main(String[] args) {
        //创建一个list集合
        Set<Student> set = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge()- o2.getAge();
            }
        });
        //创建4个学生对象
        Student s1 = new Student("阿良", 30);
        Student s2 = new Student("阮邛", 42);
        Student s3 = new Student("宁姚", 19);
        Student s4 = new Student("左右", 48);
        Student s5 = new Student("齐静春", 45);
        //用Collections addAll
        Collections.addAll(set,s1,s2,s3,s4,s5);
        System.out.println(set);



    }
}
